function gewSprite2DCompareDepth(s1,s2)
{
  var d1 = s1.depth;var d2 = s2.depth;
  if(d1>d2)
    return 1;
  if(d1<d2)
    return -1;
  return 0;
}
function gewSprite2D()
{
  this.v0 = new gewVec2();
  this.v1 = new gewVec2();
  this.v2 = new gewVec2();
  this.v3 = new gewVec2();
  this.center = new gewVec2(); // The center, use as the center of rotation,scale
  // PRIVATE :
  this.translate = new gewVec2();
  this.isVisible = true;
  this.isUpdatePosition = true;
  this.isUpdateTranslate = true;
  this.isUpdateTexcoord = true;
  this.isUpdateSubTexName = false;
  this.isUpdateDepth = true;;
  this.vBufOffset = 0;
  this.iBufOffset = 0;
  this.listIndex = 0;
  this.subTexture = null;
  this.subTextureName = null;
  this.depth = 0;
  this.subRegionLeft = 0;
  this.subRegionTop = 0;
  this.subRegionWidth = 0;
  this.subRegionHeight = 0;
}
gewSprite2D.prototype.setAsRectangle = function(w,h)
{
  this.v0.x = 0;this.v0.y = 0;
  this.v1.x = w;this.v1.y = 0;
  this.v2.x = 0; this.v2.y = h;
  this.v3.x = w;this.v3.y = h;
  this.isUpdatePosition = true;
}
gewSprite2D.prototype.setPosition = function(dx, dy)
{
  this.translate.set(dx,dy);
  this.isUpdateTranslate = true;
}
gewSprite2D.prototype.setSubTexture = function(subTexName)
{
  this.subTextureName = subTexName;this.isUpdateTexcoord = true;this.isUpdateSubTexName = true;
}
gewSprite2D.prototype.setDepth = function(depth)
{
  if(this.depth!=depth)
  {
    this.depth = depth;
    this.isUpdateDepth = true;
  }
}
gewSprite2D.prototype.setVisible = function(visible)
{
  if(this.visible!=visible)
  {
    this.isVisible = visible;
    this.isUpdatePosition = true;
  }
}
gewSprite2D.prototype.setSubRegion = function(left,top,w,h)
{
  this.subRegionLeft = left;
  this.subRegionTop = top;
  this.subRegionWidth = w;
  this.subRegionHeight = h;
  this.isUpdateTexcoord = true;
}
